Date.prototype.pattern = function(fmt) {
        var o = {
            "M+": this.getMonth() + 1, //月份  
            "d+": this.getDate(), //日  
            "h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时  
            "H+": this.getHours(), //小时  
            "m+": this.getMinutes(), //分  
            "s+": this.getSeconds(), //秒  
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度  
            "S": this.getMilliseconds() //毫秒  
        };
        var week = {
            "0": "/u65e5",
            "1": "/u4e00",
            "2": "/u4e8c",
            "3": "/u4e09",
            "4": "/u56db",
            "5": "/u4e94",
            "6": "/u516d"
        };
        if (/(y+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        }
        if (/(E+)/.test(fmt)) {
            fmt = fmt.replace(RegExp.$1, ((RegExp.$1.length > 1) ? (RegExp.$1.length > 2 ? "/u661f/u671f" : "/u5468") : "") + week[this.getDay() + ""]);
        }
        for (var k in o) {
            if (new RegExp("(" + k + ")").test(fmt)) {
                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            }
        }
        return fmt;
    }
    //定义一些常量
var x_PI = 3.14159265358979324 * 3000.0 / 180.0;
var PI = 3.1415926535897932384626;
var a = 6378245.0;
var ee = 0.00669342162296594323;

function out_of_china(lng, lat) {
    return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false);
}

function transformlat(lng, lat) {
    var ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng));
    ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
    ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0;
    ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0;
    return ret
}

function transformlng(lng, lat) {
    var ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng));
    ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0;
    ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0;
    ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0;
    return ret
}

function bd09togcj02(bd_lon, bd_lat) {
    var x_pi = 3.14159265358979324 * 3000.0 / 180.0;
    var x = bd_lon - 0.0065;
    var y = bd_lat - 0.006;
    var z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_pi);
    var theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_pi);
    var gg_lng = z * Math.cos(theta);
    var gg_lat = z * Math.sin(theta);
    return [gg_lng, gg_lat]
}

function wgs84togcj02(lng, lat) {
    if (out_of_china(lng, lat)) {
        return [lng, lat]
    } else {
        var dlat = transformlat(lng - 105.0, lat - 35.0);
        var dlng = transformlng(lng - 105.0, lat - 35.0);
        var radlat = lat / 180.0 * PI;
        var magic = Math.sin(radlat);
        magic = 1 - ee * magic * magic;
        var sqrtmagic = Math.sqrt(magic);
        dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
        dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
        var mglat = lat + dlat;
        var mglng = lng + dlng;
        return [mglng, mglat]
    }
}

/**
 * GCJ02 转换为 WGS84
 * @param lng
 * @param lat
 * @returns {*[]}
 */
function gcj02towgs84(lng, lat) {
    if (out_of_china(lng, lat)) {
        return [lng, lat]
    } else {
        var dlat = transformlat(lng - 105.0, lat - 35.0);
        var dlng = transformlng(lng - 105.0, lat - 35.0);
        var radlat = lat / 180.0 * PI;
        var magic = Math.sin(radlat);
        magic = 1 - ee * magic * magic;
        var sqrtmagic = Math.sqrt(magic);
        dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI);
        dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI);
        mglat = lat + dlat;
        mglng = lng + dlng;
        return [lng * 2 - mglng, lat * 2 - mglat]
    }
}
/**
 * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换
 * 即谷歌、高德 转 百度
 * @param lng
 * @param lat
 * @returns {*[]}
 */
function gcj02tobd09(lng, lat) {
    var z = Math.sqrt(lng * lng + lat * lat) + 0.00002 * Math.sin(lat * x_PI);
    var theta = Math.atan2(lat, lng) + 0.000003 * Math.cos(lng * x_PI);
    var bd_lng = z * Math.cos(theta) + 0.0065;
    var bd_lat = z * Math.sin(theta) + 0.006;
    return [bd_lng, bd_lat]
}
var devid = "";
var detailObj = {
    deviceArr: [],
    page: 1,
    loginId: '',
    sessionData: '',
    tppage: 1,
    totalPages: 0,
    index: -1, //工地地址
    dataArr: [],
    dwData1: [],
    dwData: [],
    plateColor: 0,
    GCMC: "",
    GCDZ: "",
    TFZL: "",
    ZYCBD: "",
    YSCD: "",
    TFXNC: "",
    SFXN: "",
    SFAZS: "",
    SFSZC: "",
    fanwei: "",
    fanwei: 0,
    num: "",
    point: "",
    zyz: "0",
    bool: 0,
    ztcdevid: "",
    gdid: "",
    devid: [],
    functions: {
        init: function() {
            map = new BMap.Map("container");
            map.centerAndZoom(new BMap.Point(116.404, 39.915), 14);
            map.enableScrollWheelZoom(); //启用滚轮放大缩小，默认禁用
            map.enableContinuousZoom(); //启用地图惯性拖拽，默认禁用
            detailObj.functions.xnlx();
            detailObj.functions.dwDatainof();
            detailObj.functions.initCondition();

            detailObj.gdid = detailObj.functions.getUrlParam("gdid");

            var begintime = detailObj.functions.getDateStr(-10) + " 00:00:00";
            var endtime = detailObj.functions.getCurrentDay();
            detailObj.GCMC = detailObj.functions.getUrlParam("GCMC");
            detailObj.GCDZ = detailObj.functions.getUrlParam("GCDZ");
            detailObj.TFZL = detailObj.functions.getUrlParam("GCXZ");
            if (detailObj.functions.getUrlParam("FANWEI")) {
                detailObj.fanwei = parseInt(detailObj.functions.getUrlParam("FANWEI"));
            } else if (detailObj.functions.getUrlParam("fanwei")) {
                detailObj.fanwei = parseInt(detailObj.functions.getUrlParam("fanwei"));
            }

            detailObj.ZYCBD = detailObj.functions.getUrlParam("JSDW");
            detailObj.YSCD = detailObj.functions.getUrlParam("SGDW");
            detailObj.TFXNC = detailObj.functions.getUrlParam("JLDW");
            detailObj.SFXN = detailObj.functions.getUrlParam("SFXN");
            detailObj.SFAZS = detailObj.functions.getUrlParam("SFAZS");
            detailObj.SFSZC = detailObj.functions.getUrlParam("SFSZC");

            detailObj.num = detailObj.functions.getUrlParam("num");
            detailObj.point = detailObj.functions.getUrlParam("point");
            if (detailObj.GCMC != "undefined") {
                $("#GCMC").text(detailObj.GCMC);
            }
            if (detailObj.TFZL != "undefined") {
                $("#GCXZ").text(detailObj.TFZL);
            }
            if (detailObj.YSCD != "undefined") {
                $("#SGDW").text(detailObj.YSCD);
            }

            if (detailObj.GCDZ != "undefined") {
                $("#GCDZ").text(detailObj.GCDZ);
                $("#GCDZ1").text(detailObj.GCDZ);
            }
            if (detailObj.ZYCBD != "undefined") {
                $("#JSDW").text(detailObj.ZYCBD);
            }
            if (detailObj.TFXNC != "undefined") {
                $("#JLDW").text(detailObj.TFXNC);
            }
            if (detailObj.SFXN != "undefined") {
                $("#SFXN").text(detailObj.SFXN);
            }
            if (detailObj.SFAZS != "undefined") {
                $("#SFAZS").text(detailObj.SFAZS);
            }
            if (detailObj.SFSZC != "undefined") {
                $("#SFSZC").text(detailObj.SFSZC);
            }

            // if (detailObj.num == "5") {
            //     $("#img").css("display", "none");
            //     $("#myVideo").css("display", "block");
            //     $("#myVideo").attr("src", "video/gongdi.mp4");
            // }
            // if (detailObj.num == "4") {
            //     $("#img").css("display", "none");
            //     $("#myVideo").css("display", "block");
            //     $("#myVideo").attr("src", "video/gongdi1.mp4");
            //     detailObj.fanwei = 9;
            //     devid = "11010806001320006606";
            // }
            if (detailObj.num == "8") {

                devid = "11010806001320006606";
            }
            if (detailObj.num == "61") {
                devid = "11010805001320005183";
            }
            if (detailObj.num == "46") {
                devid = "11010808001320008501";
            }
            if (detailObj.GCMC == "北体育馆") {
                detailObj.fanwei = 7;
                detailObj.num = "54";
            }
            if (detailObj.GCMC == "清华大学综合实验楼") {
                detailObj.fanwei = 6;
                detailObj.num = "53";
            }
            if (detailObj.fanwei > 0) {
                var html_ = "";
                if (detailObj.num != "4") {
                    for (var i = 1; i <= detailObj.fanwei; i++) {
                        html_ += `<div class="gdxx_left_item">
                        <img src="gdtp/${detailObj.num}/fanwei/${detailObj.num}_0${i}.jpg" class="gdxx_left_img">
                        <p>${detailObj.GCDZ}</p>
                    </div>`;
                    }

                    $("#img").html(html_);
                }
            }
            if (detailObj.GCDZ == "海淀区颐和园路海淀体育中心内,海淀区体育局东北120米") {
                var html_ = "";
                html_ += `<div class="gdxx_left_item">
                        <img src="images/22222.png" class="gdxx_left_img">
                        <p>${detailObj.GCDZ}</p>
                    </div>`;
                $("#img").html(html_);
            }
            $("#siteAddress").text(detailObj.GCDZ);
            $("#GCMC").attr("title", detailObj.GCMC);
            $("#GCDZ").attr("title", detailObj.GCDZ);
            $("#TFZL").attr("title", detailObj.TFZL);
            $("#ZYCBD").attr("title", detailObj.ZYCBD);
            $("#YSCD").attr("title", detailObj.YSCD);
            $("#TFXNC").attr("title", detailObj.TFXNC);
            $("#SFXN").attr("title", detailObj.SFXN);
            $("#SFAZS").attr("title", detailObj.SFAZS);
            $("#SFSZC").attr("title", detailObj.SFSZC);




        },
        prevDetail: function() {},
        nextDetail: function() {},
        pagesLeft: function() {
            if (detailObj.page > 1) {
                detailObj.page -= 1;
                detailObj.functions.getztcdata();
            }

        },
        pagesRight: function() {
            if (detailObj.page <= detailObj.totalPages) {
                detailObj.page += 1;
                detailObj.functions.getztcdata();
            }

        },
        //消纳路线
        xnlx: function() {
            var point = this.getUrlParam("point");
            point = point.split(",")
            console.log(point);
            $.ajax({
                type: 'get',
                dataType: "json",
                data: {
                    gcmc: detailObj.GCMC
                },
                url: 'http://11.16.127.79:8013/VIAS/web/Accommodation/findByGcmc',
                success: function(data) {
                    if (data.length > 0) {
                        var p = wgs84togcj02(Number(point[1]), Number(point[0]));
                        p = gcj02tobd09(p[0], p[1]);
                        var start = new BMap.Point(p[0], p[1]);
                        var end = new BMap.Point(data[0].LNG, data[0].LAT);
                        var opts = {
                            position: start, // 指定文本标注所在的地理位置
                            offset: new BMap.Size(-(detailObj.GCMC.length * 13) / 2, 10) //设置文本偏移量
                        }
                        var label = new BMap.Label(detailObj.GCMC, opts); // 创建文本标注对象
                        label.setStyle({
                            color: "red",
                            fontSize: "12px",
                            height: "20px",
                            lineHeight: "20px",
                            fontFamily: "微软雅黑"
                        });
                        map.addOverlay(label);
                        var opts1 = {
                            position: end, // 指定文本标注所在的地理位置
                            offset: new BMap.Size(-(data[0].XNMC.length * 13) / 2, 10) //设置文本偏移量
                        }
                        var label1 = new BMap.Label(data[0].XNMC, opts1); // 创建文本标注对象
                        label1.setStyle({
                            color: "red",
                            fontSize: "12px",
                            height: "20px",
                            lineHeight: "20px",
                            fontFamily: "微软雅黑"
                        });
                        map.addOverlay(label1);
                        var myIcon = new BMap.Icon("images/siteBule30X30.png", new BMap.Size(20, 20)); // 设置图片偏移
                        myIcon.setImageSize(new BMap.Size(20, 20));
                        var marker = new BMap.Marker(start, { offset: new BMap.Size(0, 0), icon: myIcon });
                        map.addOverlay(marker); //
                        var myIcon1 = new BMap.Icon("images/ztc2.png", new BMap.Size(20, 20)); // 设置图片偏移
                        myIcon.setImageSize(new BMap.Size(20, 20));
                        var marker1 = new BMap.Marker(end, { offset: new BMap.Size(0, 0), icon: myIcon1 });
                        map.addOverlay(marker1); //
                        getGJinof(start, end, detailObj.functions.GJinof);
                        map.centerAndZoom(start, 10);
                    } else if (detailObj.GCMC != null) {

                        var p = wgs84togcj02(Number(point[1]), Number(point[0]));
                        p = gcj02tobd09(p[0], p[1]);
                        var start = new BMap.Point(p[0], p[1]);
                        var end = new BMap.Point(116.80933, 40.3221);
                        var opts = {
                            position: start, // 指定文本标注所在的地理位置
                            offset: new BMap.Size(-(detailObj.GCMC.length * 13) / 2, 10) //设置文本偏移量
                        }
                        var label = new BMap.Label(detailObj.GCMC, opts); // 创建文本标注对象
                        label.setStyle({
                            color: "red",
                            fontSize: "12px",
                            height: "20px",
                            lineHeight: "20px",
                            fontFamily: "微软雅黑"
                        });
                        map.addOverlay(label);
                        var xnmc = "密云区河南寨镇荆栗园村渣土消纳场所"
                        var opts1 = {
                            position: end, // 指定文本标注所在的地理位置
                            offset: new BMap.Size(-(xnmc.length * 13) / 2, 10) //设置文本偏移量
                        }
                        var label1 = new BMap.Label(xnmc, opts1); // 创建文本标注对象
                        label1.setStyle({
                            color: "red",
                            fontSize: "12px",
                            height: "20px",
                            lineHeight: "20px",
                            fontFamily: "微软雅黑"
                        });
                        map.addOverlay(label1);
                        var myIcon = new BMap.Icon("images/siteBule30X30.png", new BMap.Size(20, 20)); // 设置图片偏移
                        myIcon.setImageSize(new BMap.Size(20, 20));
                        var marker = new BMap.Marker(start, { offset: new BMap.Size(0, 0), icon: myIcon });
                        map.addOverlay(marker); //
                        var myIcon1 = new BMap.Icon("images/ztc2.png", new BMap.Size(20, 20)); // 设置图片偏移
                        myIcon.setImageSize(new BMap.Size(20, 20));
                        var marker1 = new BMap.Marker(end, { offset: new BMap.Size(0, 0), icon: myIcon1 });
                        map.addOverlay(marker1); //
                        getGJinof(start, end, detailObj.functions.GJinof);
                        map.centerAndZoom(start, 10);
                    } else {
                        // alert("暂无消纳路线")
                        var p = wgs84togcj02(Number(point[1]), Number(point[0]));
                        p = gcj02tobd09(p[0], p[1]);
                        map.centerAndZoom(new BMap.Point(p[0], p[1]), 14);
                        map.enableScrollWheelZoom(); //启用滚轮放大缩小，默认禁用
                        map.enableContinuousZoom(); //启用地图惯性拖拽，默认禁用
                        var start = new BMap.Point(p[0], p[1]);
                        var mar = new BMap.Marker(new BMap.Point(p[0], p[1]));
                        map.addOverlay(mar)


                    }

                }
            })

        }, //轨迹上图
        GJinof: function(data) {
            if (data.message == "ok") {
                var pts = data.results[0].path.split(",");
                var points = [];
                for (var i = 0; i < pts.length; i += 2) {
                    points.push(new BMap.Point(pts[i], pts[i + 1]));
                }
                var polyline = new BMap.Polyline(points, { strokeWeight: 5, strokeColor: "red" });
                map.addOverlay(polyline);

            }
        },
        initCondition: function() {
            $("#report").off("click").on("click", function() {
                    layui.use('layer', function() {
                        var layer = layui.layer;
                        layer.open({
                            type: 2,
                            fixed: true,
                            title: ['重点车辆研判报告列表', 'font-size: 22px;color: rgb(49, 70, 89);'],
                            closeBtn: 1,
                            scrollbar: false,
                            maxmin: false,
                            content: '/vias_app/views/vias/urbanManagementLawEnforcement/chgzhf/reportOnlinePreview.html',
                            area: ['1000px', '800px'],
                            end: function() {}
                        });
                    });
                })
                //显示无牌车添加事件获取点击的值
            layui.use(['layer', 'form'], function() {
                var layer = layui.layer,
                    $ = layui.jquery,
                    form = layui.form; //必须先声明 
            });
        },
        tzztc: function() {

            // window.open("http://11.16.127.79/vias_app/views/vias/snapshot/ztc/ztc.html?token=undefined&subMenu=ztcwf&user=undefined&screeType=undefined&devid="+ detailObj.functions.getUrlParam("deviceId")+"&beginTime="+detailObj.functions.getDateStr(-1) + " 09:00:00"+"&endTime="+ detailObj.functions.getDateStr(0)+" 09:00:00"+"&cardval=true");
            window.open("http://11.16.127.79/vias_app/views/vias/snapshot/ztc/ztc.html?token=undefined&subMenu=ztcwf&user=undefined&screeType=undefined&devid=" + detailObj.ztcdevid + "&beginTime=" + detailObj.functions.getDateStr(-1) + " 09:00:00" + "&endTime=" + detailObj.functions.getDateStr(0) + " 09:00:00" + "&cardval=true");
        },
        zyz: function(z) {
            var begintime = detailObj.functions.getDateStr(-1) + " 09:00:00";
            var endtime = detailObj.functions.getDateStr(0) + " 09:00:00";
            detailObj.zyz = z;
            detailObj.page = 1;
            $.ajax({
                type: 'get',
                dataType: "json",
                data: {
                    page: detailObj.page,
                    rows: 9,
                    plateNo: "",
                    vehicleBrand: "",
                    beginTime: begintime,
                    endTime: endtime,
                    vehicleColor: "",
                    plateColor: "",
                    showNoPlate: false,
                    sourceID: "",
                    deviceId: detailObj.ztcdevid,
                    labelTypes: "",
                    userName: "jgp",
                    isZYZ: detailObj.zyz,
                    defaultAlgorithm: false,
                    baiDuAlgorithm: false,
                    yiSaAlgorithm: false,
                    allAlgorithm: true,
                },
                url: 'http://11.16.127.79:8013/VIAS/web/ztc/findZtcData',
                success: function(data) {
                    if (data.rows.length > 0) {
                        detailObj.dataArr = data.rows;
                        detailObj.totalPages = data.totalPages;
                        var rightHTML = [];
                        len = data.rows.length;
                        for (var i = 0; i < len; i++) {
                            var html_ = `<div class="gdxx_btm_item" onclick="detailObj.functions.showmotor('${data.rows[i].SS_ID}','${data.rows[i].PASS_TIME}','${data.rows[i].DEVICE_ID}','${begintime}',this,'${data.rows[i].PLATE_NO}','${data.rows[i].PLATE_COLOR}')">
                            <p class="cph">${data.rows[i].PASS_TIME}</p>
                            <img src="${data.rows[i].STORAGE_URL3}">
                            <p>${data.rows[i].SS_APE_NAME}</p>
                        </div>`
                            rightHTML.push(html_);
                        }
                        $("#record").empty().html(rightHTML.join(''));
                    } else {
                        var noResult = '<div class="list_res_empty" style="height:2.9rem;position:relative;clear:both;">' +
                            ' <div style="width:1.42rem;height:1.75rem;position:absolute;top: 3.8rem;left: 4.8rem;margin:-0.87rem -0.71rem;background:url(images/list_res_empty.png) center center no-repeat;background-size:contain;"></div>' +
                            ' </div>';
                        $("#record").empty();
                        $("#record").append(noResult);
                    }
                }
            });
        },
        prevDetail: function() {
            if (detailObj.fanwei != 0) {
                if (detailObj.tppage > 1) {
                    detailObj.tppage -= 1;
                    $("#myVideo").css("display", "none");
                    $("#img").css("display", "block");
                    $("#img").attr('src', 'gdtp/' + detailObj.num + '/fanwei/' + detailObj.num + '_0' + detailObj.tppage + '.jpg');
                } else if (detailObj.tppage == 1 && detailObj.num == "4") {
                    $("#img").css("display", "none");
                    $("#myVideo").css("display", "block");
                    $("#myVideo").attr("src", "video/gongdi1.mp4");
                } else {
                    $("#img").attr('src', 'gdtp/' + detailObj.num + '/fanwei/' + detailObj.num + '_0' + detailObj.tppage + '.jpg');

                }
            }

        },
        bayonet: function(event) {
            var parma = "";
            var videoid = "";
            if (event.geometry != null) {
                parma = '?deviceId=' + event.geometry.devid;
                videoid = event.geometry.devid;
            } else {
                parma = '?deviceId=' + event.getAttribute("devid");
                videoid = event.getAttribute("devid");
            }

            layui.use('layer', function() {
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    fixed: true,
                    title: ['卡口详情：<span style="font-size:15px">' + event.getAttribute("devname") + '</span>', 'font-size: 22px;color: rgb(49, 70, 89);'],
                    closeBtn: 1,
                    scrollbar: false,
                    maxmin: false,
                    content: 'jiaotong/shishiSP1.html' + parma,
                    area: ['50%', '75%'],
                    cancel: function(index, layero) {
                        videoDisplayFucStop(videoid);
                    }

                });
            });
        }

        ,
        bayonetwkk: function(event) {
            var parma = "";
            var videoid = "";
            if (event.geometry != null) {
                parma = '?deviceId=' + event.geometry.devid;
                videoid = event.geometry.devid;
            } else {
                parma = '?deviceId=' + event.getAttribute("devid");
                videoid = event.getAttribute("devid");
            }

            layui.use('layer', function() {
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    fixed: true,
                    title: ['卡口详情 <span style="font-size:15px">' + event.getAttribute("devname") + '</span>', 'font-size: 22px;color: rgb(49, 70, 89);'],
                    closeBtn: 1,
                    scrollbar: false,
                    maxmin: false,
                    content: 'jiaotong/shishiSP.html' + parma,
                    area: ['100%', '100%'],
                    cancel: function(index, layero) {
                        videoDisplayFucStop(videoid);
                    }
                });
            });
        },
        spkinof: function() {
            var point = this.getUrlParam("point");
            point = point.split(",");
            $.ajax({
                type: "get",
                dataType: "json",
                async: false,
                data: {
                    httpurl: "/cloudSearch/search/nearby?location=" + point[1] + "," + point[0] + "&radius=1000&table=awkk1&page_number=1&page_size=1000&data_type=2"

                },
                url: "http://11.16.127.79:5013/VIAS/web/snapshot/baidu/CircularSearch",
                success: function(data) {
                    if (data.status == 0) {
                        console.log(getUrlParam("GCMC"));
                        //    if( getUrlParam("GCMC")=="海淀区西北旺镇新村一期公建项目"){
                        //     detailObj.devid=["11010815001320015651", "11010815001320015544", "11010815001320015548", "11010815001320015624", "11010815001320015513", "11010815001320015791", "11010815001320015545", "11010815001320015549", "11010815001320015652", "11010815001320015792", "11010815001320015524", "11010815001320015546", "11010815001320015632", "11010815001320015661", "11010826001320026039", "11010815001320015509", "11010815001320015516", "11010815001320015520", "11010815001320015525", "11010815001320015547", "11010815001320015633", "11010815001320015674", "11010815001320015502", "11010815001320015507", "11010815001320015517", "11010815001320015535", "11010815001320015538", "11010815001320015662", "11010815001320015790"]
                        //    }else{
                        $.each(data.data.list, function(i, row) {

                                detailObj.devid.push(row);
                                detailObj.ztcdevid += row.devId + ",";
                            })
                            //    }
                            //展示数据
                        detailObj.functions.spkin();

                    }
                }
            })



        },
        spkinof1: function() {
            $.getJSON("json/gdzbdw.json", function(data) {
                $.each(data, function(i, row) {
                    if (detailObj.gdid == row.gcid) {
                        detailObj.ztcdevid += row.devid + ",";
                    }
                })

                detailObj.functions.getztcdata();
            })
        },
        deviceAttend: function() {
            $.getJSON("json/gdzbdw.json", function(data) {
                var j = 0;
                $.each(data, function(i, row) {
                    if (detailObj.gdid == row.gcid) {
                        detailObj.deviceArr[j] = row.devid;

                        j = j + 1;
                        console.log(j);
                    }
                })
                $(function() {
                    console.log(detailObj.deviceArr[0])

                });
                detailObj.functions.getztcdata();
            })
        },
        spkin: function() {
            var num = 0;
            var _html = "";
            if (getUrlParam("GCMC") == "新馨苑居居区666地块及配套工程") {
                _html += `<div class="spl_res_item"  onclick="detailObj.functions.bayonet(this);" devname="24042 前屯路与后屯路交叉口"  devid="11010824001320024042"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon"><img src="images/qji2.png"><img src="images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="24042 前屯路与后屯路交叉口">24042 前屯路与后屯路交叉口</h4><p>非微卡口</p><p>东升镇</p></div></div>`;

            }
            $.each(detailObj.devid, function(i, rows) {

                if (rows.bayonet == 0) {
                    num += 1;
                    _html += `<div class="spl_res_item"  onclick="detailObj.functions.bayonet(this);" devname="${rows.devName}"  devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon"><img src="images/qji2.png"><img src="images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}">${rows.devName}</h4><p>非微卡口</p><p>${rows.streetname}</p></div></div>`;
                } else if (rows.bayonet == 1) {
                    _html += `<div class="spl_res_item"  onclick="detailObj.functions.bayonetwkk(this);" devname="${rows.devName}" devid="${rows.devId}"  style="cursor:pointer;border: 1px solid;"  ><div class="spl_res_icon" ><img src="images/wkk4.png"><img src="images/sp_licon3.png"></div><div class="spl_res_txt"><h4  title="${rows.devName}">${rows.devName}</h4><p>微卡口</p><p>${rows.streetname}</p></div></div>`;
                    num += 1;
                }

            })
            $("#kknum").text("(" + num + ")");
            $("#total").text(num);
            $("#sql_con").empty();
            $("#spl_con").html(_html);
            detailObj.ztcdevid = detailObj.ztcdevid.slice(0, detailObj.ztcdevid.length - 1);

            detailObj.functions.getztcdata();
        },
        spk: function() {
            var devid = "";
            if (detailObj.bool == 0) {

                $(".gdxx_btn").css("right", "4rem");
                $(".spl_res").css("right", "0rem");
                detailObj.bool = 1;
            } else {
                $(".gdxx_btn").css("right", "0rem");
                $(".spl_res").css("right", "-4.5rem");
                detailObj.bool = 0;
            }

            // layui.use('layer', function () {
            //     var layer = layui.layer;
            //     layer.open({
            //         type: 2,
            //         fixed: true,
            //         title: ['卡口详情：<span style="font-size:15px"></span>', 'font-size: 22px;color: rgb(49, 70, 89);'],
            //         closeBtn: 1,
            //         scrollbar: false,
            //         maxmin: false,
            //         content: 'jiaotong/shishiSP1.html?deviceId=' + devid,
            //         area: ['50%', '65%'],
            //         cancel: function (index, layero) {
            //             detailObj.functions.stopflv();
            //         }

            //     });
            // });
        },
        nextDetail: function() {
            if (detailObj.fanwei != 0) {
                if (detailObj.tppage < detailObj.fanwei) {
                    detailObj.tppage += 1;
                    $("#myVideo").css("display", "none");
                    $("#img").css("display", "block");
                    $("#img").attr('src', 'gdtp/' + detailObj.num + '/fanwei/' + detailObj.num + '_0' + detailObj.tppage + '.jpg');
                } else {
                    $("#img").attr('src', 'gdtp/' + detailObj.num + '/fanwei/' + detailObj.num + '_0' + detailObj.tppage + '.jpg');

                }
            }
        },
        stopflv: function() {

            var loginid = window.sessionStorage.getItem("videoDisplayLoginID");
            var session = window.sessionStorage.getItem("videoSession");
            if (loginid) {
                if (session != "undefined") {
                    $.ajax({
                        type: 'POST',
                        dataType: "JSON",
                        contentType: "application/json",
                        data: JSON.stringify({ "LoginID": loginid, "Session": session }),
                        url: "http://11.16.127.79:8013/Video/stopreal",
                        success: function(data) {
                            console.log(data)
                                // logout(loginid);
                        }
                    });
                } else {
                    // logout(loginid);
                }
            }
        },
        stopflvDe: function() {

            //   var loginid = window.sessionStorage.getItem("id");
            //   var session = window.sessionStorage.getItem("session");
            var loginid = loginId;
            var session = sessionId;
            console.log("loginid:" + loginid + ",session:" + session)
            $.ajax({
                type: 'POST',
                dataType: "JSON",
                async: false,
                contentType: "application/json",
                data: JSON.stringify({ "LoginID": loginid, "Session": session }),
                //url: "http://11.16.127.79:8013/Video/stopreal",
                url: ssspObj.videoStopUrl,
                success: function(data) {
                    console.log(data)
                }
            });

        },
        logout: function(loginid) {

            $.ajax({
                url: 'http://11.16.127.79:8013/Video/logout',

                type: 'post',

                contentType: "application/json",
                  //必须有
                dataType: "json",
                  //表示返回值类型，不必须
                data: JSON.stringify({ "LoginID": loginid }),
                success: function(data) {
                    console.log(data);
                }
            });
        },
        logoutDe: function() {
            var loginid = loginId;
            console.log(loginid);
            $.ajax({
                //      url: 'http://11.16.127.79:8013/Video/logout',
                url: ssspObj.videoLogoutUrl,
                type: 'post',
                async: false,
                contentType: "application/json",
                  //必须有
                dataType: "json",
                  //表示返回值类型，不必须
                data: JSON.stringify({ "LoginID": loginid }),
                success: function(data) {
                    console.log(data);
                }
            });
        },
        stopflvwkk: function() {
            var loginid = window.sessionStorage.getItem("wkkvideoDisplayLoginID");
            var session = window.sessionStorage.getItem("videoSession");
            if (loginid) {
                if (session != "undefined") {
                    $.ajax({
                        type: 'POST',
                        dataType: "JSON",
                        contentType: "application/json",

                        data: JSON.stringify({ "LoginID": loginid, "Session": session }),
                        url: "http://11.16.127.79:8013/Video/stoprealwkk",
                        success: function(data) {
                            console.log(data)
                                // logoutwkk(loginid);
                        }
                    });
                } else {
                    // logoutwkk(loginid);
                }
            }
        },
        logoutwkk: function(loginid) {
            $.ajax({
                url: 'http://11.16.127.79:8013/Video/logoutwkk',
                type: 'post',
                contentType: "application/json",
                  //必须有
                dataType: "json",
                  //表示返回值类型，不必须
                data: JSON.stringify({ "LoginID": loginid }),
                success: function(data) {
                    console.log(data);
                }
            });
        },
        showmotor: function(ssid, time, device_id, beginTime, obj, plateNo, plateColor) {
            var parma = '?ssid=' + encodeURIComponent(ssid) +
                '&time=' + encodeURIComponent(time) +
                '&deviceId=' + encodeURIComponent(device_id) +
                '&beginTime=' + encodeURIComponent(beginTime) +
                '&plateNo=' + encodeURIComponent(plateNo) +
                '&plateColor=' + encodeURIComponent(plateColor) +
                '&parentObj=detailObj';
            detailObj.index = $(obj).index();
            detailObj.plateColor = plateColor;
            layui.use('layer', function() {
                var layer = layui.layer;
                layer.open({
                    type: 2,
                    fixed: true,
                    title: ['一车一档详情', 'font-size: 22px;color: rgb(49, 70, 89);'],
                    closeBtn: 1,
                    scrollbar: false,
                    maxmin: false,
                    content: '/vias_app/views/vias/snapshot/ztc/oneCarToInfo.html' + parma,
                    area: ['100%', '100%'],
                    end: function() {
                        // 暂时不用
                    }
                });
            });
        },
        getzyzAction: function() {
            var obj = document.getElementsByName("zyzCheck");
            var check_val = [];
            if (obj.length > 0) {
                for (k in obj) {
                    if (obj[k].checked)
                        check_val.push(Number(k) + 1);
                }
                return check_val.join(',');
            } else {
                return "";
            }


        },
        dwDatainof: function() {
            detailObj.functions.spkinof();
            // $.ajax({
            //     type: 'get',
            //     dataType: "json",
            //     data: {
            //         httpurl: "/cloudSearch/search/basic?table=awkk1&page_size=10000&data_type=2"
            //     },
            //     url: "http://11.16.127.79:5013/VIAS/web/snapshot/baidu/BayonetMarking",
            //     success: function(data) {
            //         detailObj.dwData1 = data.data.list;
            //         var dwData = data.data.list;
            //         $.each(dwData, function(i, row) {
            //             if (row.bayonet == 1) {
            //                 detailObj.dwData.push({

            //                     type: 'Point',
            //                     coordinates: row.shape.coordinates,
            //                     devname: row.devName,
            //                     devid: row.devId,
            //                     streetname: row.streetname,
            //                     bayonet: row.bayonet

            //                 })
            //             } else {
            //                 detailObj.dwData.push({

            //                     type: 'Point',
            //                     coordinates: row.shape.coordinates,
            //                     devname: row.devName,
            //                     devid: row.devId,
            //                     streetname: row.streetname,
            //                     bayonet: row.bayonet

            //                 })
            //             }
            //         })

            //     }
            // });
        },

        //获取url后的参数值
        getUrlParam: function(key, url) {
            var href = url || window.location.href;
            var url = href.split("?");
            if (url.length <= 1) {
                return "";
            }
            var params = url[1].split("&");

            for (var i = 0; i < params.length; i++) {
                var param = params[i].split("=");
                if (key == param[0]) {
                    if (url[2] != undefined) {
                        return decodeURIComponent(param[1] + '?' + url[2]);
                    }
                    return decodeURIComponent(param[1]);
                }
            }
        },
        //获取前后的时间  返回的时间格式为'2018-04-28 00:00:00'  n为正数 往后n天  n为负数 往前n天
        getCurrentDay: function(n) {
            var today = new Date(),
                date;
            return n ? (new Date(today.getTime() + n * 1000 * 60 * 60 * 24)).pattern("yyyy-MM-dd HH:mm:ss") : new Date().pattern("yyyy-MM-dd HH:mm:ss")
        },
        wkkid: function(id) {
            var devid = "";
            $.each(detailObj.dwData1, function(i, row) {
                var bool = detailObj.functions.confirmEnding(row.devId, id);
                if (bool) {
                    devid = row.devId;

                }
            })
            return devid;
        },
        confirmEnding: function(str, target) {
            // 请把你的代码写在这里
            var start = str.length - target.length;
            var arr = str.substr(start, target.length);
            if (arr == target) {
                return true;
            }
            return false;
        },
        getDateStr: function(AddDayCount) {
            var dd = new Date();
            dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期
            var y = dd.getFullYear();
            var m = (dd.getMonth() + 1) < 10 ? "0" + (dd.getMonth() + 1) : (dd.getMonth() + 1); //获取当前月份的日期，不足10补0
            var d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate(); //获取当前几号，不足10补0
            return y + "-" + m + "-" + d;
        },
        getztcdata: function() {
            var begintime = detailObj.functions.getDateStr(-1) + " 09:00:00";
            var endtime = detailObj.functions.getDateStr(0) + " 09:00:00";
            console.log(detailObj.ztcdevid + "---------------------------");
            if (detailObj.ztcdevid != null && detailObj.ztcdevid != "") {
                $.ajax({
                    type: 'get',
                    dataType: "json",
                    data: {
                        page: detailObj.page,
                        rows: 6,
                        plateNo: "",
                        vehicleBrand: "",
                        beginTime: begintime,
                        endTime: endtime,
                        vehicleColor: "",
                        plateColor: "",
                        showNoPlate: true,
                        sourceID: "",
                        deviceId: detailObj.ztcdevid,
                        labelTypes: "",
                        userName: "jgp",
                        isZYZ: "",
                        defaultAlgorithm: false,
                        baiDuAlgorithm: false,
                        yiSaAlgorithm: false,
                        allAlgorithm: true,
                    },
                    url: 'http://11.16.127.79:8013/VIAS/web/ztc/findZtcData',
                    success: function(data) {
                        console.log(data);
                        if (data.rows.length > 0) {
                            detailObj.dataArr = data.rows;
                            detailObj.totalPages = data.totalPages;
                            var rightHTML = [];
                            len = data.rows.length;
                            for (var i = 0; i < len; i++) {
                                var html_ = `<div class="gdxx_btm_item" onclick="detailObj.functions.showmotor('${data.rows[i].SS_ID}','${data.rows[i].PASS_TIME}','${data.rows[i].DEVICE_ID}','${begintime}',this,'${data.rows[i].PLATE_NO}','${data.rows[i].PLATE_COLOR}')">
                            <p class="cph">${data.rows[i].PASS_TIME}</p>
                            <img src="${data.rows[i].STORAGE_URL3}">
                            <p>${data.rows[i].SS_APE_NAME}</p>
                        </div>`
                                rightHTML.push(html_);
                            }
                            $("#record").empty().html(rightHTML.join(''));
                        } else {
                            var noResult = '<div class="list_res_empty" style="height:2.9rem;position:relative;clear:both;">' +
                                ' <div style="width:1.42rem;height:1.75rem;position:absolute;top: 3.8rem;left: 4.8rem;margin:-0.87rem -0.71rem;background:url(images/list_res_empty.png) center center no-repeat;background-size:contain;"></div>' +
                                ' </div>';
                            $("#record").empty();
                            $("#record").append(noResult);
                        }
                    }
                });
            }
        }
    }
}

function getGJinof(start, end, fun) {
    $.ajax({
        type: 'get',
        dataType: "json",
        data: {
            httpurl: "/cloudsearch?output=json&index=direction&action=route&origin=" + start.lat + "," + start.lng + "&destination=" + end.lat + "," + end.lng + "&waypoints=&mode=CAR&tactics=1"
        },
        url: "http://11.16.127.79:5013/VIAS/web/snapshot/baidu/BayonetMarking",
        success: function(data) {
            fun(data);
        }
    })
}